# 修改apt默认的镜像源
# tmux 开启 8910雪花ID服务
# 安装 nginx 并配置 用户名和密码
# 安装python 包
# tmux 开启scrapyd服务

FROM wfarn86/python3.8-requests
ENV DEBIAN_FRONTEND noninteractive
ENV TZ Asia/Shanghai
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
#ADD . /srv/scrapyd_deploy
WORKDIR /root

# 创建scrapyd 配置文件夹
RUN mkdir /etc/scrapyd
# 拷贝配置文件
COPY ./scrapyd.conf /etc/scrapyd
COPY ./require.txt /root
COPY ./scrapydweb_settings_v10.py /root
COPY ./tmux_start.py /root
COPY ./sources.list /etc/apt
#RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak

RUN set -eux \
    && apt-get update \
    && apt install -y tmux \
    && apt install -y openssh-server

#RUN echo "PermitEmptyPasswords yes" >> /etc/ssh/sshd_config
# 配置ssh可以 root远程登录
RUN echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
RUN echo root:123456 | chpasswd
# 重启 ssh 服务

# 安装python依赖
RUN pip install -r require.txt -i https://pypi.doubanio.com/simple/


#CMD python tmux_start.py
COPY ./tmux_start.py /root

#RUN chmod 755 tmux_start.py && python tmux_start.py
#ENTRYPOINT ["python tmux_start.py"]
EXPOSE 6800
#CMD /bin/bash
ENTRYPOINT rm -rf twistd.pid && python tmux_start.py && service ssh restart &&/bin/bash
#RUN /usr/bin/tmux new-session -d -s snow
#RUN /usr/bin/tmux send-keys -t snow "snowflake_start_server --address=127.0.0.1 --port=8910" ENTER
# 创建软链接
#RUN ln -sfn /opt/conda/bin/python /usr/bin/python

#COPY ./sources.list /etc/apt/sources.list
#RUN apt-get update
#
#RUN mkdir /root/.pip
#COPY ./pip.conf /root/.pip/pip.conf
#RUN pip install --upgrade pip
#RUN pip install -r requirements.txt

#COPY ./scrapyd.conf /etc/scrapyd/

#CMD [ "sh", "entrypoint.sh" ]